package com.gitee.shigen.oss.cloud;

import com.gitee.shigen.oss.config.CloudStorageConfig;
import com.gitee.shigen.oss.enums.CloudStorageTypeEnum;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * 文件上传Factory
 *
 * @author shigenfu
 */
@Component
public class OSSFactory {

    @Resource
    private CloudStorageConfig config;

    public CloudStorageService build() {
        if (config.getType().equals(CloudStorageTypeEnum.QINIU.getCode())) {
            return new QiniuCloudStorageService(config);
        } else if (config.getType().equals(CloudStorageTypeEnum.ALIYUN.getCode())) {
            return new AliyunCloudStorageService(config);
        } else if (config.getType().equals(CloudStorageTypeEnum.QCLOUD.getCode())) {
            return new QcloudCloudStorageService(config);
        } else if (config.getType().equals(CloudStorageTypeEnum.MINIO.getCode())) {
            return new MinioStorageService(config);
        }
        return null;
    }

}
